package com.orange.lockscreensettings.version;

import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;

import com.orange.lockscreensettings.R;

public class AboutOrangeLSActivity extends Activity {

	private static final String	PACKAGE_LOCKSCREEN_SETTINGS	= "com.orange.lockscreensettings";

	private TextView			mVersion;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.about_lockscreen);
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
				R.layout.about_lockscreen_title);

		mVersion = (TextView) findViewById(R.id.version);

		String versionName = getVersionName(PACKAGE_LOCKSCREEN_SETTINGS);
		mVersion.setText(getString(R.string.about_version, versionName));
	}

	private String getVersionName(String packageName) {
		String versionName = "";

		try {
			PackageInfo info = getPackageManager().getPackageInfo(packageName,
					PackageManager.GET_ACTIVITIES);
			versionName = info.versionName;
		} catch (NameNotFoundException e) {
		}

		return versionName;
	}
}
